package com.mmd.manage.web;

import com.mmd.bean.CODE;
import com.mmd.bean.WebJsonBean;
import com.mmd.intercepter.AdminInterceptor;
import com.mmd.manage.service.VatService;
import com.mmd.manage.vo.VatEo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * vat
 */
@RequestMapping(value = "/api/vat")
@Controller
public class VatController {

	@Autowired
	private VatService vatService;

	/**
	 * 新增vat
	 * @param eo
	 * @return
	 */
	@RequestMapping(value = "/addVat")
	@ResponseBody
	public WebJsonBean addVat(VatEo eo) {
		String account = AdminInterceptor.getUserLoginContext().getAccount();
		eo.setAccount(account);
		return new WebJsonBean(CODE.SUCCESS,vatService.addVat(eo));
	}

	@RequestMapping(value = "/modifyVat")
	@ResponseBody
	public WebJsonBean modifyVat(VatEo eo) {
		String account = AdminInterceptor.getUserLoginContext().getAccount();
		eo.setAccount(account);
		return new WebJsonBean(CODE.SUCCESS,vatService.modifyVat(eo));
	}

	/**
	 * 获取用户vat
	 * @return
	 */
	@RequestMapping(value = "/getVatByAccount")
	@ResponseBody
	public WebJsonBean getVatByAccount(){
		String account = AdminInterceptor.getUserLoginContext().getAccount();
		return new WebJsonBean(CODE.SUCCESS, vatService.getVatByAccount(account));
	}
}
